package com.xiaomi.mapper;

import com.xiaomi.entity.AlertRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AlertMapper {
    @Insert("insert into alert_record(vehicle_frameNumber, rule_code, alert_level, alert_time) " +
            "values " +
            "(#{vehicleFrameNumber}, #{ruleCode}, #{alertLevel}, #{alertTime})")
    void save(AlertRecord alert);

    /**
     * 查找数据库中有没有车一样，规则一样，相应码一样的，如果有则不需要添加
     * @param alert
     * @return
     */
    @Select("select * from alert_record where vehicle_frameNumber = #{vehicleFrameNumber} and rule_code = #{ruleCode} and alert_level = #{alertLevel}")
    AlertRecord selectByAlert(AlertRecord alert);

}
